perm filename F8F[F8,ALS] blob sn#295388 filedate 1977-07-25 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	* TREE MOBS PLY0 COL0 PLOC KLOC ELOC PLYT PLYD PLYH START
C00011 ENDMK
CāŠ—;
* TREE MOBS PLY0 COL0 PLOC KLOC ELOC PLYT PLYD PLYH START
	JMP	STAR
*
*RAM assignments
TREE	EQU	H'0E10'		Tree data (14 blocks of 16 bytes each)
MOBS	EQU	H'0F00'		Mobility and DJ flags (14 bytes)
PLY0	EQU	H'0F0E'		Place for player's ply depth choice
COL0	EQU	H'0F0F'		Place for color choice (next after PLY0)
*
*Scratch pad assignments
PLOC	EQU	3		LISU value for ACTIVE and PASSIVE
KLOC	EQU	4		LISU value for KING's and special data
ELOC	EQU	5		LISU value for EMPTY's area
ISA	EQU	O'30'		ISAR value for active area
ISP	EQU	O'34'		ISAR value for passive
ISK	EQU	O'40'		ISAR value for kings
ISE	EQU	O'51'		ISAR value for empty (with offset)

*Mimimum ply depths
PLYT	EQU	H'FE'		Ply depth for Robot Tom (stored as neg.)
PLYD	EQU	H'FD'		Ply depth for Robot Dick
PLYH	EQU	H'FC'		Ply depth for Robot Harry
*
*Set up initial boards both in SC and in blocks 0 and 1
STAR	LISU	PLOC
	LISL	0
	LI	H'FF'		Full double row of pieces
	LR	I,A		First byte of ACTIVE
	LI	H'F0'		1 row only
	LR	I,A		Second byte of active
	CLR
	LR	I,A		Part of board with no active pieces
	LR	I,A		Part of board with no active pieces
	LR	I,A		Part of board with no passive pieces
	LR	I,A		Part of board with no passive pieces
	LI	H'F'		1 row only (in second half of byte)
	LR	I,A		byte of PASSIVE
	LI	H'FF'		Full double row of pieces
	LR	I,A		Last byte with Passive pieces
	LISU	KLOC
	LISL	0
	CLR
	LR	I,A		4 king bytes next (all empty)
	LR	I,A
	LR	I,A
	LR	I,A
	LI	H'F0'		The 4 bits for pieces that can move RF
	LR	I,A		The MOVE byte
	LIS	H'4'		BYTE # 1 RF normal move with no piece debit
	LR	I,A		
	LI	H'80'		Set score at -128 (lose, unless move is found)
	LR	I,A
	CLR			With position advantage of 0
	LR	I,A
	DCI	PLY0		Location to store ply depth number
	LIS	PLYT		The minimum setting for PLY0 (presently -2)
	ST
	CLR
	LR	8,A		Set for black to be active
	ST			Save so 8 can be freed as required
	DCI	TREE		Set to start of data space (now H'0E10')
	LR	H,DC		Note: H always points to start of a block
	PI	SCRA	Ready for opponents move if he elects BLACK
	PI	SCRA	Ready for Machine to play BLACK
	LR	DC,H
* MEN KING REDP BLKP
*
* Code to read the internal representation of the board and to put the
* required pieces into the board image.
*
*This code requires a minimum of subroutine nesting and of space but it is
*slow.  Speed should not be important since the code is used only twice
*per move.  It presently requires 147 bytes (115+32).
*
MEN	LISU	O'3'		Start with pieces
	LIS	H'1'		1 for red pieces (shown first always)
	LR	4,A		To specify piece color (1 red, 0 black, -1 king)
	LR	A,8		Get color of active
	NS	8		Set status
	LISL	O'7'		Decrement if black is active and shift right
	BZ	MEN1		Black is active (Appears at bottom of screen)
	LISL	O'0'		Red is active, increment and shift left
MEN1	LIS	H'3'
	LR	1,A		To count bytes
	LIS	H'7'
	LR	2,A		To count bits
MEN2	DCI	TAB1		Starting address for the byte location table
	LR	A,1		This byte number
 	SL	1		Locations occupy 2 bytes each
	ADC
	LM			Get the location
	LR	QU,A		and save it in Q
	LM
	LR	QL,A
	LR	A,8
	NS	8
	BZ	MEN5		Black is active
	LR	A,I		Increment if red is active
	BR	MEN4
MEN3	LR	A,3
	SL	1		and shift left
MEN4	LR	3,A
	NI	H'80'		(done this way for symetry, BC would work)
	BZ	MEN9
	BR	MEN8
MEN5	LR	A,D		Decrement if black is active
	BR	MEN7
MEN6	LR	A,3
	SR	1		and shift right
MEN7	LR	3,A
	NI	H'1'
	BZ	MEN9
MEN8	DCI	TAB2		Relative-locations-of-squares table
	LR	A,2		This square
	ADC
	LM			Get square displacement
	LR	DC,Q		Recall the location for the input byte
	ADC			This is the square position
	LR	A,4		Identify type of piece
	NS	4
	BM	PUTK		To put down a king
	LIS	H'4'		Prepare for a piece
	LR	5,A		To count lines
	LI	H'20'		Skip the first 4 lines (4*8)
	ADC
	XDC
	DCI	BLKP		Anticipate a black piece
	BZ	PUTL		A black piece (status bit still ok)
	DCI	REDP		No, it's a red piece
	BR	PUTL
PUTK	LIS	H'2'		Only 3 lines for a crown
	LR	5,A
	LIS	H'8'		To skip 1 line
	ADC
	XDC
	DCI	KING
PUTL	LM			Put loop
	XDC
	ST
	LIS	H'7'		To next line on screen (less increment)
	ADC
	XDC
	DS	5
	BP	PUTL		Loop
MEN9	DS	2
	BM	ME10
	LR	A,8
	NS	8
	BZ	MEN6		Black active case
	BR	MEN3		Red active case
ME10	DS	1
	BP	MEN2		For the next input byte
	LR	A,4
	NS	4
	BM	BDEX		Exit from board routine
	DS	4
	BP	MEN1		Go round again for black pieces
	LISU	H'4'		Get set for kings
	LR	A,8
	NX	8
	LISL	H'3'		Decrementing case
	BZ	MEN1
	LISL	H'0'		Incrementing case
	BR	MEN1
TAB1	DC	H'0F10'		Byte 3 location (a 2 bytes entry)
	DC	H'0D70'		Byte 2 location
	DC	H'0CD0'		Byte 1 location
	DC	H'0C30'		Byte 0 location
TAB2	DC	D'86'		Relative-square-position table
	DC	D'84'
	DC	D'82'
	DC	D'80'		Second row of squares starts here
	DC	D'07'
 	DC	D'05'
	DC	D'03'
	DC	D'01'		First playable square off-set
KING	DC	B'01011010'	King's crown representation
	DC	B'00111100'
	DC	B'00111100'
REDP	DC	B'00111100'	Red piece representation
	DC	B'01111110'
	DC	B'01111110'
	DC	B'01111110'
	DC	B'00111100'
BLKP	DC	B'00111100'	Black piece representation
	DC	B'01000010
	DC	B'01000010
	DC	B'01000010
	DC	B'00111100'
POIN	DC	B'00001111'	Pointer representation
	DC	B'00000001'
	DC	B'00000011'
	DC	B'00000011'